﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class BlotScrew : BaseRepository_DT<BlotScrewInfo>, IBlotScrew
    {
        #region 静态变量部分
        private const string PARM_BLOTSCREW_PRODUCTSN = "@ProductSN";
        private const string PARM_BLOTSCREW_RECORDTIME = "@RecordTime";
        private const string PARM_BLOTSCREW_USERID = "@UserID";
        #endregion

        #region 数据检索部分
        public IList<BlotScrewInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public BlotScrewInfo LoadEntity<T1>(T1 productSN)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = productSN;
            return ExcuteSqlToGetEntity("BlotScrew_selectLastbySN", parm);
        }

        public IList<BlotScrewInfo> GetBlotScrewsbySN(string productSN)
        {
            SqlParameter parm = GetParameter();
            parm.Value = productSN;
            return ExcuteSqlToGetEntities("BlotScrew_selectbySN", parm);
        }

        public IList<BlotScrewInfo> GetBlotScrewsbyDT(DateTime starttime,DateTime stoptime)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = starttime;
            parms[1].Value = stoptime;
            return ExcuteSqlToGetEntities("BlotScrew_selectbyDT", parms);
        }
        #endregion


        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override BlotScrewInfo GetEntityRecord(SqlDataReader rdr)
        {
            BlotScrewInfo pro = new BlotScrewInfo(rdr.GetValue(0).ToString(), rdr.GetDateTime(1), rdr.GetValue(2).ToString());
            return pro;
        }

        public override BlotScrewInfo GetEntityRecord()
        {
            BlotScrewInfo pro = new BlotScrewInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "BlotScrew_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_BLOTSCREW_PRODUCTSN, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_BLOTSCREW_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_BLOTSCREW_RECORDTIME, SqlDbType.DateTime, 8),
                    new SqlParameter(PARM_BLOTSCREW_USERID, SqlDbType.NVarChar, 10),
                };
            return parms;
        }

        public override void SetParameters(BlotScrewInfo blotScrew, params SqlParameter[] Parms)
        {
            Parms[0].Value = blotScrew.ProductSN;
            Parms[1].Value = blotScrew.RecordTime;
            Parms[2].Value = blotScrew.UserID;
        }
        #endregion
    }
}
